<template>
  <div>
    <!--    <div class="search">
      <i class="el-icon-search"></i>

    </div>-->
    <p class="title">{{ themeInfo.theme_name }}</p>

    <div class="container">
      <div class="aTitle"><i></i>请选择述职人员</div>
      <el-table :data="tableData" border>
        <el-table-column
          type="index"
          label="序号"
          style="text-align: center"
          width="60"
        />
        <el-table-column prop="per_name" width="70px" label="姓名">
        </el-table-column>
        <el-table-column prop="per_department" label="中心/部门">
          <template slot-scope="scope">{{
            scope.row.per_department
              ? scope.row.per_department
              : scope.row.per_center
          }}</template>
        </el-table-column>

        <el-table-column label="操作" width="70px" align="center">
          <template slot-scope="scope" class="btnContainer">
            <el-button
              class="btn"
              type="primary"
              size="small"
              :disabled="
                ledictHasSumit.some(
                  (v) =>
                    v ==
                    `${$route.query.theme_id}-${
                      scope.row.per_id
                    }-${dateFormat()}`
                )
              "
              @click="handleClick(scope.row)"
              >评分</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import dayjs from 'dayjs';
export default {
  name: 'personList',
  data() {
    return {
      themeInfo: {},
      tableData: [],
      ledictHasSumit: [],
    };
  },
  created() {
    this.getTheme();
    this.getList();
  },
  methods: {
    dateFormat() {
      return dayjs().format('YYYY-MM-DD');
    },
    async getTheme() {
      const res = await this.$Request({
        url: `/theme/detail/${this.$route.query.theme_id}`,
      });
      this.themeInfo = res.body;
    },
    async getList() {
      let ledictHasSumit = JSON.parse(
        localStorage.getItem('ledictHasSumit') || '[]'
      );
      this.ledictHasSumit = ledictHasSumit;
      console.log(ledictHasSumit);
      const res = await this.$Request({
        url: `/personnel/list/${this.$route.query.theme_id}`,
      });
      this.tableData = res.body || [];
    },
    handleClick(row) {
      this.$router.push({
        //核心语句
        path: '/score', //跳转的路径
        query: {
          //路由传参时push和query搭配使用 ，作用时传递参数
          per_id: row.per_id,
          theme_id: this.$route.query.theme_id,
        },
      });
    },
  },
};
</script>

<style scoped>
.title {
  font-size: 20px;
  font-weight: bold;
  line-height: 2;
  text-align: left;
  margin-bottom: 20px;
  margin-top: 40px;
  margin-left: 40px;
}
.aTitle {
  text-align: left;
  line-height: 2;
  border: 1px solid rgba(222, 227, 231, 1);
  background-color: rgba(241, 249, 255, 1);
  padding-left: 15px;
  margin-bottom: 40px;
}
.aTitle i {
  display: inline-block;
  width: 5px;
  height: 40px;
  position: relative;
  top: 8px;
  background-color: rgba(66, 164, 255, 1);
  margin-right: 10px;
}
.container {
  width: calc(100% - 80px);
  margin: 0 40px;
}
.btnContainer {
  text-align: center;
}
.btn {
  margin: 0 auto;
}
.search {
  width: 100px;
  height: 100px;
  text-align: center;
  line-height: 120px;
  background-color: #fff;
  border: 1px solid #999;
  z-index: 999;
  position: fixed;
  bottom: 60px;
  right: 60px;
}
.search i {
  font-size: 25px;
}
</style>
